package com.zhanglu.fun.services.datacenter.role;

import com.zhanglu.fun.services.datacenter.entity.ApplicationRole;
import com.zhanglu.fun.tookit.json.JsonTools;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @description
 * @Auther zhanglu
 * @Date 2017/9/21 下午1:49
 */
@RestController
@RequestMapping("/application")
@Slf4j
public class ApplicationRoleRouter {
    @Autowired
    private ApplicationRoleService applicationRoleService;

    @ApiOperation(value = "根据用户id查询权限", notes = "根据用户id查询权限")
    @ApiResponses({@ApiResponse(code = 200, message = "请求成功", response = Long.class, responseContainer = "List")})
    @GetMapping("/roles/{userId}")
    public List<ApplicationRole> getApplicationRolesByUserId(@PathVariable("userId") Long userId) {
        log.info("getApplicationRoles receive param:[login id:{}]", userId);
        return applicationRoleService.getApplicationRolesByUserId(userId);
    }
}
